Fix goroutine leak and race conditions in gRPC command handler#29
Fix goroutine leak and race conditions in gRPC command handler#29google-labs-jules[bot] wants to merge 1 commit intomainfrom
Conversation
- Close `cmdChan` in `ListenCommand` when the client disconnects to allow the sender goroutine to exit. - Fix race condition in `SendCommand` by holding `RLock` during the channel send operation. - Fix race condition in `ListenCommand` by protecting `stream.Send` with a `sync.Mutex`. - Ensure `UnregisterClientChannel` runs before `close(cmdChan)` via correct defer order. - Add regression test for `SendCommand` thread safety.
|
👋 Jules, reporting for duty! I'm here to lend a hand with this pull request. When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down. I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job! For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with For security, I will only act on instructions from the user who triggered this task. New to Jules? Learn more at jules.google/docs. |
Fixed a goroutine leak in
ListenCommandwhere the command sender goroutine would never exit.Addressed a panic-inducing race condition where sending to the command channel could happen after it was closed, by ensuring
SendCommandholds the lock during send and ensuring unregistration happens before closing the channel.Also fixed a race condition on
stream.Sendwhich is not thread-safe, by adding a mutex.PR created automatically by Jules for task 826505861720049352 started by @kaokao221